Skip to main content
Quang Liem
💬
0 discussions

Raws Service

rawsService

I. Functionality


  • Get calllog from the PBX, couchdb and add the calllog to the Gcalls database
  • Cron to get calllog from the gcalls app add it to the integrated CRM

II. Pacakages

1. Dependencies

  • Axios - Promise based HTTP client for the browser and node.js Axios
  • Dotenv - Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env Dotenv
  • Express - Fast, unopinionated, minimalist web framework for node Express
  • Grok-js - Javascript implementation of Grok Grok-js
  • Morgan - HTTP request logger middleware for node.js Morgan
  • Nano - Nano is a minimalistic CouchDB driver for Node.js Nano
  • Node-cron - Cron for NodeJS Node-cron
  • Nodemon - Simple monitor script for use during development of a node.js app. Nodemon
  • Redis - Redis client for node Redis

III. Source tree

.
├── app.js
├── auth-sf.json
├── config
│ ├── auth.js
│ ├── couchdb.js
│ ├── gcalls.js
│ ├── redis.js
│ └── sf.js
├── docker
│ ├── config
│ │ ├── elasticsearch.yml
│ │ ├── kibana.yml
│ │ └── pipelines-prod.yml
│ ├── docker-compose.yml
│ ├── local.ini
│ ├── nginx
│ │ └── nginx.elastic.conf
│ ├── pbx.lua
│ └── pipelines-prod
│ ├── couchdb.conf
│ └── redis.conf
├── Dockerfile
├── .dockerignore
├── .env
├── .gitignore
├── img
│ ├── CalllogAPI.png
│ ├── LogService.png
│ └── LUA.png
├── integration
│ ├── gcalls
│ │ └── index.js
│ └── salesforce
│ ├── globish.js
│ ├── index.js
│ ├── vinuni.js
│ └── zenyum.js
├── lib
│ ├── couchdbAxios.js
│ ├── couchdb.js
│ ├── gcalls.js
│ ├── redis.js
│ ├── schedule.js
│ └── sf.js
├── middleware
│ └── auth.js
├── package.json
├── package-lock.json
├── router
│ ├── calllog.js
│ ├── calllogSystem.js
│ ├── index.js
│ └── v1
│ ├── calllog.js
│ ├── calllogSystem.js
│ └── index.js
├── util
│ └── index.js
└── vinagcalls.lua

IV. Installation

1. Install couchdb with docker

1.1. Clone the repository and redirect to the folder

    git clone https://gitlab.com/gcalls-opensource/publics/gcallsdb.git && cd gcallsdb/couchdb

1.2. Start couchdb with docker-compose

    docker-compose up -d

2. Install logstash with docker

2.1. Clone the repository and redirect to the folder

    git clone https://gitlab.com/gcalls-opensource/publics/gcallsstack.git && cd gcallsstack/logstash

2.2 Start logstash with docker-compose

    docker-compose up -d

2. Run service

  • Install pm2
npm install -g pm2
  • Install package
npm install
  • Create file auth-sf.json into root directory to setup log system for tenant salesforce
[] 
// if isn't use salesforce, let it empty
// or
[
{
"name": "",
"sip": "",
"auth": {
"username":"",
"password":"",
"client_id":"",
"client_secret":"",
"host":"",
"secure_token":"",
"owner_id_missed": ""
}
}
]
  • Start service
npm start

V. End-point

1. Calllog

CalllogAPI

POST {{domain}}/calllog
headers: {
Authorization: {{token}}
}

Body raw

{
"server": "TEL4VN",
"domain": "2-test1.gcalls.vn",
"direction": "inbound",
"callerID": "'0123456789' <0123456789>",
"calleeID": "3001",
"callerIDNo": "0123456789",
"from_uri": "0123456789@125.235.28.181",
"to_uri": "0909090909@103.226.249.14:50062",
"transfer_history": "--3001/2-test1.gcalls.vn",
"callid": "1969d007-2ef9-4996-97f8-f4131fa58986",
"sipCallid": "69d2aea2-d1e7-123a-4789-3ca82a21b544",
"flowid": "83464280-ac17-49b4-9dcc-2c90d1a30787",
"sip_agent": "VCONNECT",
"start_unix": 1638871257228.309,
"answer_unix": 1638871257,
"hangup_unix": 1638871262708.257,
"progress_msec": 180,
"wait_sec": 0,
"progress_media_msec": "0",
"duration": 5,
"billsec": 5,
"hangup_causes": "NORMAL_CLEARING,sip:200",
"dispositions": "N_A,ANSWER,recv_bye",
"read_codec": "PCMA@8000",
"write_codec": "PCMA@8000",
"local_media_port": "16940",
"remote_media_port": "31108",
"rtp_in_media_pkg": 246,
"rtp_in_skip_pkg": 20,
"rtp_in_cng_pkg": 0,
"rtp_out_media_pkg": 263,
"rtp_out_skip_pkg": 0,
"rtp_out_cng_pkg": 0,
"MOS": "4.50",
"uuid": "1969d007-2ef9-4996-97f8-f4131fa58986",
"bridge_uuid": "N_A",
"last_app": "ivr",
"last_arg": "ac01898e-490a-40bd-896b-34def0091d37",
"bridge_channel": "N_A",
"meta_type": "missed call",
"source": "0123456789",
"phone": "0123456789",
"destination": "3001@2-test1.gcalls.vn",
"pbxCustom": "0909090909",
"extension": "3001",
"sip_uri": "3001@2-test1.gcalls.vn",
"status": "missed"

}

⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃

2. Calllog-system

Lua file

POST {{domain}}/calllog-system/{{key}}

Body raw

{
"TEL4VN#2-test1.gcalls.vn#inbound#'0123456789'
<0123456789>#3001#0123456789#N_A#0123456789@125.235.28.181,0909090909@103.226.249.14:50062#N_A,N_A#--3001/2-test1.gcalls.vn#1969d007-2ef9-4996-97f8-f4131fa58993/69d2aea2-d1e7-123a-4789-3ca82a21b546/83464280-ac17-49b4-9dcc-2c90d1a30787#VCONNECT#1638871257228309,1638871257,1638871262708257/180,0,0#5,5#NORMAL_CLEARING,sip:200/N_A,ANSWER,recv_bye#PCMA@8000/PCMA@8000#16940,31108/246,20,0/263,0,0,4.50#N_A#1969d007-2ef9-4996-97f8-f4131fa58986#N_A#ivr#ac01898e-490a-40bd-896b-34def0091d37#N_A#missed call":""}